﻿
#include <iostream>
#include <fstream>
using namespace std;
int main()
{   char looking[10] = { 0 };
    char name[10] = { 0 };
    if (fopen("data.txt", "r") == NULL) {
        printf("未找到数据文件，请确保data.txt文件在程序目录中后重试。");
        return 0;
    }
    ifstream fp;   
    fp.open("data.txt", ios::in);
    printf("欢迎使用用药助手1.0！\n提示：输入后按回车确认。\n");
    int pai = fp.get();
    int lie = fp.get();
    fp.close();
    while(1){
    fp.open("data.txt", ios::in);
    fp.get(); fp.get();
    printf("请输入药品名称："); scanf("%s", &name);
    for (int a = 1; a <= pai; a++)
    {
        for (int b = 1; b <= lie; b++)
        {
            fp.getline(looking, 10, '#');
            if (strcmp(looking, name) == 0) {
                printf("%s在%d排%d列。\n", name, a, b); 
            }
        }
    }  
    fp.close();}
    system("pause");
    return 0;
}

